package com.lw;

/**
 * 底层数字
 */
public class BottomNum {

    public BottomNum() {
    }

    private void printlnDataBottom(){
        for (int i = 0; i < GameUtil.MAP_W+2; i++) {
            System.out.println("i="+i);
            int[] lines = GameUtil.DATA_BOTTOM[i];
            for (int j = 0; j < GameUtil.MAP_H+2; j++) {
                System.out.print(lines[j]+",");
            }
            System.out.println();
        }
    }

    /**
     * 标记数字
     */
    public void newNum(){
//        System.out.println("方法调用栈：com.lw.BottomNum.newNum");
//        GameUtil.printStackTrace();
        //遍历地图
        for (int i = 1; i <= GameUtil.MAP_W; i++) {
            for (int j = 1; j <= GameUtil.MAP_H; j++) {
                if (GameUtil.DATA_BOTTOM[i][j] == -1) {//此处是雷区，则遍历雷区周围
                    //九宫格遍历法
                    for (int k = i - 1; k <= i + 1; k++) {
                        for (int l = j-1; l <= j+1; l++) {
                            if(GameUtil.DATA_BOTTOM[k][l]>=0){//遍历到不是雷，则此位置处加一
                                GameUtil.DATA_BOTTOM[k][l]++;
                                if(GameUtil.DATA_BOTTOM[k][l]>8){
                                    System.out.println("生成数字："+k+","+l+" "+GameUtil.DATA_BOTTOM[k][l]);
//                                    printlnDataBottom();
                                }
                            }
                        }
                    }
                }
            }
        }
    }
}
